package com.kaifamiao.set;

import java.util.*;

/**
 * Set集合特点是不能包含重复元素 (即不重复)
 */
public class SetFeature {

    public static void main(String[] args) {

        Set<String> set = new HashSet<>();

        set.add( "李芳" );
        System.out.println( set );

        set.add( "儿女" );
        System.out.println( set );

        set.add( "农丰" );
        System.out.println( set );

        Set<String> names = Set.of( "李元芳", "李元霸", "李元婴" );
        System.out.println( names );
        System.out.println( names.getClass() );

        Collection<String> c = List.of( "李元芳", "李元霸", "李元婴", "李元芳", "李元霸", "李元婴" );
        System.out.println( c );

        Set<String> unique = Set.copyOf( c );
        System.out.println( unique );
    }

}
